//
//  HMuserCount.swift
//  WeiBo
//
//  Created by 李立达 on 15/12/7.
//  Copyright © 2015年 heima11. All rights reserved.
//

//public func encodeWithCoder(aCoder: NSCoder)
//public init?(coder aDecoder: NSCoder) // NS_DESIGNATED_INITIALIZER

import UIKit

class HMuserCount: NSObject , NSCoding{

    
    var access_token : String?
    var uid : String?
    var expires_in : NSTimeInterval = 0{
        didSet{
        
            expriesDate = NSDate(timeIntervalSinceNow: expires_in)
            print(expriesDate)
        }
    }
    var expriesDate :NSDate?
    var remind_in : String?
    var avatar_large :String?
    var screen_name : String?
    
     init(dict : [String : AnyObject]) {
        
        super.init()
    
    setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    override var description: String {
        let keys = ["uid", "expires_in", "access_token", "remind_in","avatar_large","screen_name"]
        return dictionaryWithValuesForKeys(keys).description
    }
    func encodeWithCoder(aCoder: NSCoder) {
        
        aCoder.encodeObject(uid, forKey: "uid")
        aCoder.encodeObject(expriesDate, forKey: "expriesDate")
        aCoder.encodeObject(access_token, forKey: "access_token")
        aCoder.encodeObject(avatar_large, forKey: "avatar_large")
        aCoder.encodeObject(screen_name, forKey: "screen_name")
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        
        uid = aDecoder.decodeObjectForKey("uid") as? String
        expriesDate = aDecoder.decodeObjectForKey("expriesDate") as? NSDate
        access_token = aDecoder.decodeObjectForKey("access_token") as? String
        avatar_large = aDecoder.decodeObjectForKey("avatar_large") as? String
        screen_name = aDecoder.decodeObjectForKey("screen_name") as? String
    
    }
}
